//
//  RevealViewController.m
//  RJETGeography
//
//  Created by RJET04 on 2023/8/23.
//

#import "RevealViewController.h"

@interface RevealViewController ()

@property (nonatomic, strong) ZYView *navView;
@property (nonatomic, strong) ZYImageView *backImgV;
@property (nonatomic, strong) ZYLabel *backLab;
@property (nonatomic, strong) ZYLabel *titleLab;
@property (nonatomic, strong) ZYLabel *submitLab;
@property (nonatomic, strong) ZYLabel *resLab;

@end

@implementation RevealViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupBgView];
    [self setupNaviViews];
    [self setupContentViews];
}

- (void)setupBgView
{
    ZYImageView *bgView = [ZYImageView createZYImageView:^(ZYImageView *imageView) {
        imageView.frameBlock(CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT))
        .imageBlock([UIImage imageNamed:@"bj"]);
    }];
    [self.view addSubview:bgView];
    [self.view sendSubviewToBack:bgView];
}

- (void)setupNaviViews
{
    self.navView = [ZYView createZYView:^(ZYView *view) {
        view.frameBlock(CGRectMake(0, 0, SCREEN_WIDTH, kStatusBarHeight+kNavBarHeight))
        .backGroundColorBlock(THEME_COLOE);
    }];
    [self.view addSubview:self.navView];
    
    self.backImgV = [ZYImageView createZYImageView:^(ZYImageView *imageView) {
        imageView.frameBlock(CGRectMake(10, kStatusBarHeight+kNavBarHeight/2-ARROW_HEIGHT/2, ARROW_WIDTH, ARROW_HEIGHT))
        .imageBlock([UIImage imageNamed:@"back"]);
    }];
    [self.navView addSubview:self.backImgV];
    
    self.backLab = [ZYLabel createZYLabel:^(ZYLabel *label) {
        label.frameBlock(CGRectMake(CGRectGetMaxX(self.backImgV.frame)+3, kStatusBarHeight, 40, kNavBarHeight))
        .backGroundColorBlock([UIColor clearColor])
        .fontBlock([UIFont systemFontOfSize:17])
        .textColorBlock([UIColor whiteColor])
        .textAlignmentBlock(NSTextAlignmentLeft);
    }];
    [self.navView addSubview:self.backLab];
    
    self.titleLab = [ZYLabel createZYLabel:^(ZYLabel *label) {
        label.frameBlock(CGRectMake(CGRectGetMaxX(self.backLab.frame), kStatusBarHeight, SCREEN_WIDTH-2*CGRectGetMaxX(self.backLab.frame), kNavBarHeight))
        .backGroundColorBlock([UIColor clearColor])
        .fontBlock([UIFont systemFontOfSize:18])
        .textColorBlock([UIColor whiteColor])
        .textAlignmentBlock(NSTextAlignmentCenter);
    }];
    [self.navView addSubview:self.titleLab];
    
    self.backLab.text = self.backText;
    self.titleLab.text = self.titleText;

    
    ZYView *backV = [ZYView createZYView:^(ZYView *view) {
        view.frameBlock(CGRectMake(0, kStatusBarHeight, CGRectGetMaxX(self.backLab.frame), kNavBarHeight))
        .backGroundColorBlock([UIColor clearColor])
        .userEnableBlock(YES);
    }];
    [self.navView addSubview:backV];
    
    __weak typeof(self) weakSelf = self;
    backV.singalTapBlock = ^{
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };
}

- (void)setupContentViews
{
    self.resLab = [ZYLabel createZYLabel:^(ZYLabel *label) {
        label.frameBlock(CGRectMake(12, SCREEN_HEIGHT/2-65, SCREEN_WIDTH-24, 50))
        .textAlignmentBlock(NSTextAlignmentCenter)
        .fontBlock([UIFont systemFontOfSize:18])
        .textColorBlock([UIColor blackColor]);
    }];
    [self.view addSubview:self.resLab];
    
    self.resLab.numberOfLines = 0;
    self.resLab.lineBreakMode = NSLineBreakByWordWrapping;
    
    if ([self.env isEqualToString:@"zh"]) {
        self.resLab.text = [NSString stringWithFormat:@"您的%@计算结果为:%@", self.titleText, self.res];
    }else{
        self.resLab.text = [NSString stringWithFormat:@"your %@ calcuation result is: %@", self.titleText, self.res];
    }
    
    CGFloat X = 50;
    self.submitLab = [ZYLabel createZYLabel:^(ZYLabel *label) {
        label.frameBlock(CGRectMake(X, CGRectGetMaxY(self.resLab.frame)+30, SCREEN_WIDTH-2*X, 50))
        .backGroundColorBlock(BTN_BG_COLOE)
        .textColorBlock([UIColor whiteColor])
        .textAlignmentBlock(NSTextAlignmentCenter)
        .textBlock(self.model.textjson.currency.backText)
        .userEnableBlock(YES);
        
        label.layer.cornerRadius = 5;
        label.layer.masksToBounds = YES;
    }];
    [self.view addSubview:self.submitLab];
    
    __weak typeof(self) weakSelf = self;
    self.submitLab.singalTapBlock = ^{
        
        [weakSelf.navigationController popToRootViewControllerAnimated:YES];
    };
    
}

@end
